from appium import webdriver
import time
from appium.webdriver.common.appiumby import By

# 连接配置信息
des = {
    "platformName": "Android",
    "platformVersion": "7.1.2",
    "deviceName": "emulator-5554",
    "appPackage": "com.android.settings",
    "appActivity": ".Settings"
}

# 实例化驱动对象
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", des)


# # swipe滑动事件
# for i in range(5):
#     driver.swipe(500, 1450, 500, 450, 500)

# # scroll滑动事件
# start_ele = driver.find_element(By.XPATH, "//*[@text='更多']")
# end_ele = driver.find_element(By.XPATH, "//*[@text='建议']")
# driver.scroll(start_ele, end_ele)

# # drag拖拽事件
# start_ele = driver.find_element(By.XPATH, "//*[@text='更多']")
# end_ele = driver.find_element(By.XPATH, "//*[@text='建议']")
# driver.drag_and_drop(start_ele, end_ele)

# 模拟热启动
driver.background_app(5)

time.sleep(5)
driver.quit()
